package t20250228_sqlparse.lineage;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
@EqualsAndHashCode
public class Field {

  private static String DELIMITER = ".";

  @JSONField(serialize = false)
  public String catalog;
  @JSONField(serialize = false)
  public String database;
  @JSONField(serialize = false)
  public String table;
  @JSONField(serialize = false)
  public String column;
  @JSONField(serialize = false)
  public int index;
  @JSONField(serialize = false)
  public int level;
  @JSONField(serialize = false)
  public boolean outerLayer;

  @JSONField(serialize = false)
  public String getTablePath() {
    return catalog + DELIMITER + database + DELIMITER + table;
  }

  public String getFieldName() {
    return database + DELIMITER + table + DELIMITER + column;
  }

  @Override
  protected Field clone() {
    return new Field(this.catalog, this.database, this.table, this.column, this.index, this.level, this.outerLayer);
  }
}
